<?php
require_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'init.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'supercompare.inc.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'examplequeries.inc.php';

class PrettyPrintQueryTest extends PHPUnit_Framework_TestCase {

	var $parser;
	var $optimiser;
	var $examplequeries;
	
	protected function setUp()
    {
        $this->parser = ARC2::getSPARQLParser();
		$this->examplequeries = new ExampleQueries();
    }
 
    protected function tearDown()
    {
        $this->parser = NULL;
    }

	function test_typical_query() {
		$queryInfo = $this->examplequeries->makeTypicalQueryNeedingToKnowClassLessRestrictiveThanPredicate();
								
		$pp_query = $this->prettyPrintQuery($queryInfo);
		$this->assertEquals($pp_query,$this->examplequeries->pp_typicalQueryNeedingToKnowClassLessRestrictiveThanPredicate,
						"pretty printed query not as expected");
	}
	
	function test_typical_opt_query() {
		$queryInfo = $this->examplequeries->makeQuery($this->examplequeries->optimisedTypicalQueryNeedingToKnowClassLessRestrictiveThanPredicate);
								
		$pp_query = $this->prettyPrintQuery($queryInfo);
		$this->assertEquals($pp_query,$this->examplequeries->optimisedTypicalQueryNeedingToKnowClassLessRestrictiveThanPredicate,
						"pretty printed query not as expected [[$pp_query]]");
	}

	
	
	function prettyPrintQuery($queryInfo) {
		$pp = new PrettyPrintQuery($queryInfo);
		return $pp->getQuery();
	}


}


?>